//
//  JLCLSplashViewController.m
//  JLCLTestDemo
//
//  Created by Eren on 2022/3/29.
//

#import "JLCLSplashViewController.h"

@interface JLCLSplashViewController ()<JLCLSplashAdDelegate>

@end

@implementation JLCLSplashViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self show];
    UIButton *btn = [self createBtnWithTitle:@"开屏广告" withToTop:kNavBarAndStatusBarHeight +20 wihtHeight:40 withSelect:@selector(show)];
    [self.view addSubview:btn];
}


- (void)show {
    dispatch_async(dispatch_get_main_queue(), ^{
        self.aCenter = [[JLCLAdManagementCenter alloc] init];
        JLCLSplashAdData *data = [[JLCLSplashAdData alloc] init];
        data.ad_id = kJLCLTestSplashAdID;// 广告位ID   必传
        data.timeoutInterval = 5;
        data.location = 1;// 位置标识符 多个同类型广告时请准确填写位置标识 默认为1
        data.delegate = self;
        data.rootViewController = self;
        [self.aCenter jlcl_showSplashAd:data];
    });
}

- (void)jlcl_splashAdDidLoad {
    NSLog(@"开屏广告加载完成");
}

- (void)jlcl_splashAdDidClick {
    NSLog(@"开屏广告被点击");
}

- (void)jlcl_splashAdDidLoadFailWithError:(NSString *)error {
    NSLog(@"开屏广告加载失败 = %@",error);
    
}

- (void)jlcl_splashAdDidClickSkipOrClose {
    NSLog(@"开屏广告已关闭");
    [self removeAD];
}

- (void)removeAD {
    if (self.aCenter) {
        [self.aCenter jlcl_closeSplashAd];
        self.aCenter = nil;
    }
}

@end
